package hospital.serviceImpl;

import java.util.List;
import java.util.Set;

import hospital.dao.DoctorDao;
import hospital.model.DocScheduleModel;
import hospital.model.EmpInfoModel;
import hospital.model.PatientInfoModel;
import hospital.model.RecordDetailModel;
import hospital.model.VisitRecordModel;
import hospital.service.DoctorService;

public class DoctorServiceImpl implements DoctorService {

	private DoctorDao doctorDao;

	@Override
	public boolean createRecord(VisitRecordModel visitRecord) {
		return doctorDao.insertCreateRecord(visitRecord);
	}

	public DoctorDao getDoctorDao() {
		return doctorDao;
	}

	public void setDoctorDao(DoctorDao doctorDao) {
		this.doctorDao = doctorDao;
	}

	@Override
	public List<PatientInfoModel> getPatientResult(long userId, String firstname, String lastname) {
		return doctorDao.selectGetPatientResult(userId, firstname, lastname);
	}

	@Override
	public List<RecordDetailModel> getRecordDetailList(long patientId) {
		return doctorDao.selectGetRecordDetailList(patientId);
	}

	@Override
	public List<EmpInfoModel> getDocResult(long userId, String firstname, String lastname) {
		return doctorDao.selectGetDocResult(userId, firstname, lastname);
	}

	@Override
	public List<EmpInfoModel> getStaffResult(long userId, String firstname, String lastname) {
		return doctorDao.selectGetStaffResult(userId, firstname, lastname);
	}

	@Override
	public boolean grantPermission(long patientId, long doctorId, long staffId) {
		return doctorDao.updateGrantPermission(patientId, doctorId, staffId);
	}

	@Override
	public List<PatientInfoModel> getAllPatients() {
		return doctorDao.selectGetAllPatients();
	}

	@Override
	public List<RecordDetailModel> searchRecord(long patientId, long recordTimeStart, long recordTimeEnd,
			String diagnosis, String drug, String comment) {
		return doctorDao.selectSearchRecord(patientId, recordTimeStart, recordTimeEnd, diagnosis, drug, comment);
	}

	@Override
	public List<DocScheduleModel> lookupAppointment() {
		return doctorDao.selectLookupAppointment();
	}

	@Override
	public boolean checkPatientExist(long patientId) {
		return doctorDao.selectCheckPatientExist(patientId);
	}

	@Override
	public List<PatientInfoModel> getPatientResultDefault(long userId, String firstname, String lastname) {
		return doctorDao.selectGetPatientResultDefault(userId, firstname, lastname);
	}

	@Override
	public boolean checkDoctorExist(long doctorId) {
		return doctorDao.selectCheckDoctorExist(doctorId);
	}

	@Override
	public boolean checkStaffExist(long staffId) {
		return doctorDao.selectCheckStaffExist(staffId);
	}

	@Override
	public Set<EmpInfoModel> getGrantedDoc(long patientId) {
		return doctorDao.selectGetGrantedDoc(patientId);
	}

	@Override
	public Set<EmpInfoModel> getGrantedStf(long patientId) {
		return doctorDao.selectGetGrantedStf(patientId);
	}

	@Override
	public EmpInfoModel getCurrentDoctor(long doctorId) {
		return doctorDao.selectGetCurrentDoctor(doctorId);
	}

	@Override
	public Set<EmpInfoModel> removeDocPermission(long patientId, long doctorId) {
		return doctorDao.deleteRemoveDocPermission(patientId, doctorId);
	}

	@Override
	public Set<EmpInfoModel> removeStfPermission(long patientId, long staffId) {
		return doctorDao.deleteRemoveStfPermission(patientId, staffId);
	}

	@Override
	public String checkPassword() {
		return doctorDao.selectCheckPassword();
	}

	@Override
	public boolean changePassword(String password) {
		return doctorDao.updateChangePassword(password);
	}

}
